//
//  YKPerformanceManageViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/17.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKPerformanceManageViewController.h"
#import "YKClientListHeaderView.h"
#import "YKDataHeaderView.h"
#import "YKPerformanceManageItem.h"
@interface YKPerformanceManageViewController ()
@property (nonatomic, strong) NSString *startTime;
@property (nonatomic, strong) NSString *endTime;
@end

@implementation YKPerformanceManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"业绩管理";
    
    @weakify(self)
    YKDataHeaderView *headerView = [[YKDataHeaderView alloc]init];
    headerView.dateChangeBlock = ^(NSString *start, NSString *end) {
        self_weak_.startTime = start;
        self_weak_.endTime = end;
        [self_weak_ startLoadData];
    };
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.trailing.equalTo(self.view);
    }];
    
    YKClientListHeaderView* listHeaderView = [[YKClientListHeaderView alloc]initWithTitles:@[@"业务员",@"销售业绩",@"排名"] weights:@[@1,@1,@1]];
    
    [self.view addSubview:listHeaderView];
    listHeaderView.backgroundColor = [UIColor tf_colorWithHexString:@"#1EADFC"];
    
    listHeaderView.textFont = [UIFont systemFontOfSize:16];
    [listHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.view);
        make.top.equalTo(headerView.mas_bottom);
    }];
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self.view);
        make.top.equalTo(listHeaderView.mas_bottom);
    }];
    
    self.tableView.tableFooterView = [UIView new];
    
    self.dataSource.totalPageKey = @"page.totalpage";
    self.dataSource.currentPageKey = @"curpage";
    [self startLoadData];
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    if (self.dataSource.manager.sections.count > 0) {
        [self startLoadDataSilently];
    }
}

- (NSDictionary *)pageViewControllerParameters {
    return @{
             kTFPageViewControllerItemClass: [YKPerformanceManageItem class],
             kTFPageViewControllerModelClass:[YKPerformanceManageModel class],
             kTFPageViewControllerRequestURL:@"achievementManager/searchAchievementIntegralLogList.htm",
             kTFPageViewControllerDataKeyPath:@"list",
             kTFPageViewControllerRequestParameter:@{@"startTime":self.startTime?:@"", @"endTime":self.endTime?:@""}
             };
}



@end
